home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Suzy B Software 2
/
Suzy B Software CD-ROM 2 (1994).iso
/
extras
/
programm
/
gemfsc20
/
gemfsc20.lzh
/
GEMFUNCS
/
APLMALLO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-20
|
1KB
|
58 lines
/**************************************************************************
* APLMALLO.C - Internal service routines apl_malloc(), apl_free().
*
* All memory allocation done by GemFast internals goes through these
* routines. By default, the standard runtime lib allocator is used.
*************************************************************************/
#include "gemfintl.h"
#include <stdlib.h>
#if defined(LATTICE) || defined(__GNUC__) || defined(__TURBCOC__)
#define DefaultAllocate(size) malloc(size)
#define DefaultRelease(block) free(block)
#else
#define DefaultAllocate(size) lalloc(size)
#define DefaultRelease(size) free(size)
#endif
typedef void * (VPFUNC) __PROTO((unsigned long));
typedef void (VFUNC) __PROTO((void *));
static VPFUNC *allocator = NULL;
static VFUNC *releaser = NULL;
void *apl_malloc(size)
unsigned long size;
{
if (allocator) {
return (*allocator)(size);
} else {
return DefaultAllocate(size);
}
}
void apl_free(block)
void *block;
{
if (block) {
if (releaser) {
(*releaser)(block);
} else {
DefaultRelease(block);
}
}
}
void apl_mmvectors(newalloc, newrelease)
void *newalloc;
void *newrelease;
{
if (newalloc && newrelease) {
allocator = (VPFUNC *)newalloc;
releaser = (VFUNC *)newrelease;
}
}